//
// Created by LYS on 2022/2/23.
//

#include<iostream>
#include<cstdio>
#include<cmath>
using  namespace std;

const int MAX_N = 10000+5;
const int MAX_C = 10000+5;
const int ST_SIZE = (1<<15)-1;

// input
int N,C;
int L[MAX_N];
int S[MAX_C],A[MAX_N];

// The data maintained by the Segment Tree
double vx[ST_SIZE],vy[ST_SIZE];
double ang[ST_SIZE];

// current angles for querying change of angles
double prv[MAX_N];

// initialize
// k means number,l and r represent a range [l,r) maintained by the current node
void init(int k,int l,int r){
    ang[k] = vx[k] = 0.0;

    if(r-l == 1){
        // leaf node
        vy[k] = L[l];
    }
    else{
        // inner node
        int chl = k *2 + 1, chr = k * 2 + 2;
        init(chl,l,(l+r) / 2);
        init(chr,(l+r)/2,r);
        vy[k] = vy[chl] + vy[chr];
    }
}

// rotate to angle a between s and s+1
// v means number,l and r represent a range [l,r) maintained by the current node
void change(int s,double a,int v,int l,int r){
    if(s<=l) return;
    else if(s<r){
        int chl = v*2+1,chr=v*2+2;
        int m = (l+r)/2;
        change(s,a,chl,l,m);
        change(s,a,chr,m,r);
        if(s <= m) ang[v] += a;

        double sn = sin(ang[v]), cs =cos(ang[v]);
        vx[v] = vx[chl] + (cs*vx[chr] - sn*vy[chr]);
        vy[v] = vy[chl] + (sn*vx[chr] + cs*vy[chr]);
    }
}

void solve(){
    // initialize
    init(0,0,N);
    for(int i=1;i<N;i++) prv[i] = M_PI;

    // operation
    for(int i=0;i<C;i++){
        int s = S[i];
        double a = A[i] / 360.0 * 2 * M_PI;

        change(s,a-prv[s],0,0,N);
        prv[s] = a;

        printf("%.2f %.2f\n",vx[0],vy[0]);

    }
}

int main(){

    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);
    bool first = true;
    while(cin>>N>>C){
        if(!first){
            printf("\n");
        }
        else{
            first = false;
        }

        for(int i=0;i<N;i++){
            cin >> L[i];
        }
        for(int i=0;i<C;i++){
            cin >> S[i] >> A[i];
        }
        solve();
    }

    return 0;
}